package com.jin.webvideo.base.dc.safe.whitelist;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * 基于set实现的白名单
 *
 * @author biao532
 * @date 2023/12/03 11:19
 **/
public class SetWhitelist<E> implements Whitelist<E>{
    private Set<E> set;
    public SetWhitelist(int size) {
        set = new HashSet<>(size);
    }
    public SetWhitelist() {
        set = new HashSet<>();
    }
    public boolean add(E e) {
        return set.add(e);
    }
    public boolean addAll(Collection<E> e) {
        return set.addAll(e);
    }
    @Override
    public int size() {
        return set.size();
    }

    @Override
    public boolean contains(E o) {
        return set.contains(o);
    }
}
